#Indicator '************************************************************** '* RSI Bands Indicator (RSIBands.txt) '* by Jeremy Williams '* Dec. 10, 2007 '* '* Adapted from Technical Analysis of Stocks and Commodities '* April 2008 '* '* Summary: '* '* This indicator calculates price bands based on critical values '* of the RSI indicator. This indicator should be used along side the '* Omnilanguage indicator, "StdRSI.txt" for best results. For more '* information see "RSI Bands" in the April 2008 issue of Technical '* Analysis of Stocks and Commodities. '* '* Parameters: '* '* Period - Specifies the number of periods used in the RSI calculation '* '* TargetRSI- Specifies the RSI level indicated by the band '* '************************************************************** #Param "Period",14 #Param "TargetRSI",30 Dim Gain As Single Dim Loss As Single Dim Diff As Single Dim P As Single Dim N As Single Dim HCTMRSIT As Single 'Hypothetical Close to match RSI Target ' Calculate the gains and losses Diff = c - c[1] Gain = IIF(Diff > 0 , Diff, 0) Loss = IIF(Diff < 0, 0 - Diff,0) ' Calculate the value of the band If HCTMRSIT[1] > c[1] Then HCTMRSIT = C[1] + P[1] - P[1]*Period - ((N[1]*Period)-N[1])*TargetRSI/(TargetRSI - 100) Else HCTMRSIT = C[1] - N[1] - P[1] + N[1]*Period + P[1]*Period +(100*P[1])/TargetRSI - (100*P[1]*Period)/TargetRSI End If ' Update the averages for tommorrow's calculation P = ((Period-1)*P[1] + Gain)/Period N = ((Period-1)*N[1] + Loss)/Period 'Plot The Band PlotPrice("RSI Band", HCTMRSIT) ' Return the value calculated by the indicator Return HCTMRSIT